Skip to content

Fix --architecture mode's fabricated edge; bump codegraph pin to 1.5.0 - #23

Merged
inth3shadows merged 2 commits into
masterfrom
fix-architecture-mode-test-failures
Aug 5, 2026
Merged

Fix --architecture mode's fabricated edge; bump codegraph pin to 1.5.0#23
inth3shadows merged 2 commits into
masterfrom
fix-architecture-mode-test-failures

Conversation

@inth3shadows

Copy link
Copy Markdown
Owner

Summary

  • The committed architecture diagram had a spurious render/callgraph.js -> test/run.js edge, caused by a codegraph 1.4.1 bug (fixed upstream in 1.5.0's LITERAL_RECEIVER_TYPES change): calls on a literal receiver (e.g. /regex/.test(x)) fell through to bare-name matching against any same-named project symbol. render/callgraph.js uses .test() heavily, and its own test runner defines test(name, fn) — so those unrelated builtin calls were bare-name-colliding into a fabricated edge. Verified by direct side-by-side reproduction against a locally-installed 1.4.1 vs. a fresh 1.5.0 index.
  • Fixing that surfaced a real, separate, pre-existing gap: --architecture mode has never captured calls made from inside anonymous top-level callbacks (e.g. test('...', () => { realCall() })) in either codegraph version, because filterCallableSymbols dropped file-kind nodes from the probed set. codegraph attributes such calls to the enclosing file, and codegraph callees <fileBasename> is a real, working query against it — codeshot just never issued it. Renamed to unwrapQueryNodes, stopped dropping file-kind entries. The regenerated diagram now shows the real, correctly-directed edge (test/run.js -> render/callgraph.js, weight 29).
  • CI's codegraph pin moves 1.4.1 → 1.5.0 so --check validates against a version that behaves correctly, instead of faithfully re-validating a fabricated artifact on every push.
  • README's Requirements section now states the 1.5.0 floor and why.
  • TECHNICAL.md's Known Limitations gains a note on the new file-basename collision risk (same class as the existing symbol-name collision limitation) and documents the new file-node probing.

Test plan

  • npm test — 89/89 pass (both previously-failing --architecture tests now pass for real, not just skip).
  • Manually ran --architecture mode before/after: confirmed the fabricated edge is gone and the real one (correct direction) appears.
  • --check passes clean against the regenerated docs/architecture.svg + TECHNICAL.md embed.
  • Confirmed the other committed diagram (docs/buildDot-callgraph.svg, symbol mode) was unaffected — still passes --check unchanged.
  • Root-caused via direct source citations and a side-by-side 1.4.1-vs-1.5.0 reproduction, not inference from changelog prose (full investigation trail available on request).

The committed architecture diagram had a spurious render/callgraph.js
-> test/run.js edge. Root cause was a codegraph 1.4.1 bug (fixed
upstream in 1.5.0 by its LITERAL_RECEIVER_TYPES change): a call on a
literal receiver, e.g. /regex/.test(x), fell through to bare-name
matching against any same-named project symbol instead of being
recognized as a builtin. render/callgraph.js uses .test() heavily
(isTestRef, matchNotInitialized, argument parsing); its own test
runner happens to define a `test(name, fn)` helper, so those builtin
calls were fabricating an edge into test/run.js by name collision.
Confirmed by reproducing it directly against a locally-installed
1.4.1 and comparing to a fresh 1.5.0 index, side by side.

Fixing the diagram surfaced a real, separate, pre-existing gap:
--architecture mode has never captured the actual dependency (test
files calling into production code from inside anonymous callbacks,
e.g. `test('...', () => { realCall() })`) in either codegraph
version, because filterCallableSymbols excluded file-kind nodes from
probing. codegraph attributes such calls to the enclosing file when
no named function contains them, and `codegraph callees <fileBasename>`
is a real, working query against that file node -- codeshot just
never issued it. Renamed to unwrapQueryNodes and stopped dropping
file-kind entries, so the file node itself gets probed too. The
regenerated diagram now shows the real edge (test/run.js ->
render/callgraph.js) in the correct direction.

CI's codegraph pin moves from 1.4.1 to 1.5.0 so --check validates
against the version that actually behaves correctly, instead of
faithfully re-validating a fabricated artifact on every push.
Two real gaps from code review:

- probeFileEdges was counting "kind":"file" callees (unresolved
  module-level references) as full-weight real edges -- the exact
  fabricated-edge failure this branch exists to fix, just via a
  different mechanism. Symbol mode already treats these as unverified
  (dotted/gray, not a real call edge); architecture mode now skips
  them too instead of aggregating them in. Verified empirically
  against this repo's own index (0 kind:file callees among 100
  probed currently, but the guard is real and cheap).
- unwrapQueryNodes now also drops any entry with no usable string
  name, not just a missing .node -- probeFileEdges passes a symbol's
  name straight into a codegraph subprocess's argv, where an
  undefined/empty value would throw before codegraph gets a chance to
  report its own "not found", bypassing the fatal:false resilience
  meant to let one bad index entry skip past without aborting the
  whole scan.

Also verified (empirically, not just by inspection) that probing a
file node's callees doesn't double-count calls already reachable from
a named function in the same file: 0 overlaps found across all 68
probed symbols on this repo's real index. Documented the two
remaining real, un-mitigated costs (max-symbols budget now shared
between files and real symbols in an unspecified order; probe count
and wall-clock grow with file count) in TECHNICAL.md rather than
adding scope to fix them here.
@inth3shadows
inth3shadows merged commit 23f8add into master Aug 5, 2026
5 checks passed
@inth3shadows
inth3shadows deleted the fix-architecture-mode-test-failures branch August 5, 2026 18:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant